//
//  BVFullScreenPlayViewController.m
//  AFNetworking
//
//  Created by xiute on 2019/11/9.
//

#import "BVFullScreenPlayViewController.h"
#import "Masonry.h"

@interface BVFullScreenPlayViewController ()

@end

@implementation BVFullScreenPlayViewController


- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.modalPresentationStyle = UIModalPresentationFullScreen;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.playView removeFromSuperview];
    [self.view addSubview:self.playView];
    [self.playView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    __weak typeof(self)weakSelf = self;
    [self.playView setFullScreenBlock:^{
        [weakSelf.playView.playController pause];
        [weakSelf dismissViewControllerAnimated:NO completion:^{
            [weakSelf.playView.playController play];
            if (weakSelf.dismissBlock) {
                weakSelf.dismissBlock();
            }
        }];
    }];
}


- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    if (self.playView.videoSize.width > self.playView.videoSize.height) {
        return UIInterfaceOrientationMaskLandscape;
    }else {
        return UIInterfaceOrientationMaskPortrait;
    }
}


@end
